<?php

require dirname(__FILE__).'/../../../bootstrap/Doctrine.php';

$t = new lime_test(9);
$table = Doctrine::getTable('BlogCategory');

$t->diag('->retrieveActiveCategory()');

$category = $table->retrieveActiveCategory(array('sf_culture' => 'en', 'category' => 'zend-framework'));
$t->is($category['Translation']['en']['slug'], 'en-zend-framework', '->retrieveActiveCategory() returns the category');

$category = $table->retrieveActiveCategory(array('sf_culture' => 'fr', 'category' => 'zend-framework'));
$t->is($category['Translation']['fr']['slug'], 'fr-zend-framework', '->retrieveActiveCategory() returns the category');

$category = $table->retrieveActiveCategory(array('sf_culture' => 'en', 'category' => 'misc'));
$t->is($category, false, '->retrieveActiveCategory() returns NULL for unpublished category');

$category = $table->retrieveActiveCategory(array('sf_culture' => 'en', 'category' => 'foo'));
$t->is($category, false, '->retrieveActiveCategory() returns NULL for invalid category');

$t->diag('->getPublishedCategories()');

$t->is(count($table->getPublishedCategories('en')), 5, '->getPublishedCategories() returns 5 objects');
$t->is(count($table->getPublishedCategories('fr')), 5, '->getPublishedCategories() returns 5 objects');
$t->is(count($table->getPublishedCategories('de')), 0, '->getPublishedCategories() returns 0 object');

$t->diag('->retrieveBackendList()');
$q = $table->createQuery();
$t->isa_ok($table->retrieveBackendList($q), 'Doctrine_Query', '->retrieveBackendList() returns a Doctrine_Query object');
$t->is($q->count(), 6, '->retrieveBackendList() returns 6 objects');